<?php if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class Map_functions_model extends CI_Model {
	public function __construct() {
		parent::__construct();
	}

  public function get_locations($zone){
    $sql="SELECT *,aea.zone_1, (SELECT(CASE WHEN ar.account_id in (SELECT account_id from ubs_meter_readings where CONCAT(bill_year,'-',bill_month) = '2016-09') THEN 'YES' ELSE 'NO' END)) as flag 
      FROM ar_account ar
        INNER JOIN ar_entity_address aea on ar.acct_addr = aea.address_id
      where ar.loc_latitude != 0 and ar.loc_longitude != 0 and ar.status = 'ACT' and aea.zone_1 = '".$zone."'
    ";
    $query = $this->db->query($sql);
    return $query->result();
  }

  public function getzoning($zone) {
    $this->db->where('zone', $zone);
    $query = $this->db->get('ubs_zones_v');
    return $query->result();
  }


}
